package myjava.algorithm;

import java.lang.*;

public class sum {
	private static final String CLASS_METHOD_LINE_FORMAT = "%s.%s()  Line:%d  (%s)";  
	public static int sum(int i)
	{
		if(i==0)
			return 0;
		
		return i+sum(i-1);
	}
    public static void main(String[] args) {
        System.out.println(sum(9000));
        
        StackTraceElement traceElement = Thread.currentThread().getStackTrace()[1];
        String logText = String.format(CLASS_METHOD_LINE_FORMAT,  
                traceElement.getClassName(), traceElement.getMethodName(),  
                traceElement.getLineNumber(), traceElement.getFileName());  
        System.out.println(logText);
    }
}
